// axios二次封装
import http from '../request/http'

// 登录
const login =(pats)=>{
    return http.post('login',pats)
}

//用户数据
const user = (user)=>{
    return http.get(`users?query=${user.query}&pagesize=${user.pagesize}&pagenum=${user.pagenum}`)
}

// 用户添加
const addus = (add)=>{
    return http.post('users',add)
}

// 用户状态修改
const revise = (ris)=>{
    return http.put(`users/${ris.id}/state/${ris.type}`)
}

// 用户数据修改
const edits = (dit)=>{
    return http.put(`users/${dit.id}`,{email:dit.email,mibile:dit.mobile})
}

// 用户信息查询
const sear = (serch)=>{
    return http.get(`users/${serch.id}`)
}

// 用户信息删除
const del = (dels)=>{
    return http.delete(`users/${dels.id}`)
}

// 用户分配  (未完成)+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
const role = (rle)=>{
    return http.put(`users/${rle}/role`)
}

// 角色列表
const rol =(ol)=>{
    return http.get('roles',ol)
}

// 角色列表
const Permissions = ()=>{
    return http.get('roles')
}

// 权限列表
const prmion=()=>{
    return http.get('rights/list')
}

// 添加角色
const addrl=(nameRol)=>{
    return http.post('roles',nameRol)
}

// 根据id查询角色=============================(未完成)
// const rolId = (Rd)=>{
//     return http.get('roles/')
// }

// 编辑提交角色
const Editrold = (Eld)=>{
    return http.put(`roles/${Eld.id}`,Eld)
}

// 删除角色
const Del = (Dl)=>{
    return http.delete(`roles/${Dl.id}`)
}

export {login,user,addus
    ,revise,edits,sear,del,role,rol,Permissions,prmion,
    addrl,Editrold,Del
}